package com.app.view.pulltorefresh;

import android.content.Context;
import android.os.Build;
import android.support.annotation.RequiresApi;
import android.util.AttributeSet;
import android.widget.ScrollView;

/**
 * Created by Administrator on 2017/5/4.
 */

public class PullableScrollview extends ScrollView implements Pullable {


    public PullableScrollview(Context context) {
        super(context);
    }

    public PullableScrollview(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public PullableScrollview(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    public PullableScrollview(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    @Override
    public boolean canPullDown() {
        if (!canScrollVertically(-1)) {
            // 滑到RecyclerView的顶部了
            return true;
        }
        return false;
    }


    @Override
    public boolean canPullUp() {
        if (!canScrollVertically(1)) {
            return true;
        }
        return false;
    }
}
